package models;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import javax.persistence.*;

import play.db.jpa.*;

@Entity
public class SystemSDIS extends Model{
	@OneToMany
	public List<Agent> respDepartemental=new ArrayList<Agent>();

	public List<Agent> getRespDepartemental() {
		return respDepartemental;
	}
	
	public static SystemSDIS getSystemSDIS(){
		return (SystemSDIS) SystemSDIS.findAll().get(0);
	}

	public void setRespDepartemental(List<Agent> respDepartemental) {
		this.respDepartemental=respDepartemental;
	}

	public boolean isResponsableDepartemental(Agent agent) {
		if (!respDepartemental.isEmpty()){
			Iterator it=respDepartemental.iterator();
			while(it.hasNext()){
				if(it.next().equals(agent)){
					return true;
				}
			}
		}
		return false;
	}
	
	public void addRespPedago(Agent agent){
		if(!respDepartemental.contains(agent)){
			respDepartemental.add(agent);
		}
	}
}
